/*
	Copyright 2007-2010 Petr Ohlidal

	This file is a part of GrobMaker

	GrobMaker is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	GrobMaker is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with GrobMaker.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef GROBMAKER_PEGFILELIST
#define GROBMAKER_PEGFILELIST

/** @file */

#include "../Global.hpp"
#include <list>
#include <string>
//#include "../Util/FileInfo.hpp"
//#include "../InputData.hpp"

#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;

namespace GrobMaker{

class InputData;
class FileInfo;

class PegFileList{
	std::string pegName;
public:
	int pegIndex; // Remember pegs are indexed from 1
	std::list< FileInfo > files;


	PegFileList( const std::list<FileInfo>& files, int pegIndex, std::string name = std::string() ){
		this->pegIndex = pegIndex;
		this->files = files;
		this->pegName = name;
	}

	/**
	 * Returns true if element A goes before B
	 */
	static bool sortPegFileListsByPegIndex( const PegFileList& a, const PegFileList& b );

	/**
	* Looks up peg source images in a file list.
	* @param dir full path to the listed directory.
	* @param files Source list of files.
	* @return True if anything was found, false otherwise.
	*/
	static bool checkPegsDir( const fs::path& dir, const std::list<FileInfo>& files, InputData& inputData);

	const std::string& getPegName() const{
		return pegName;
	}

	bool hasPegName() const{
		return !pegName.empty();
	}

	void setPegName(const std::string& name){
		pegName=name;
	}
};

} // namespace GrobMaker

#endif //#ifndef GROBMAKER_PEGFILELIST
